#include <iostream>
#include <ctime>
#include "ThreadPool.hpp"
#include "Task.hpp"

int main()
{
    std::cout << "process runing" << std::endl;
    //ThreadPool<Task> *tp = new ThreadPool<Task>(5);
    ThreadPool<Task>::GetInstance()->Start();
    //tp->Start();

    srand(time(nullptr));


    while (true)
    {
        // 1. 构建任务
        int x = rand() % 10 + 1;
        usleep(10);
        int y = rand() % 9;

        char op = opera[rand() % opera.size()];

        Task t(x,y,op);

        // 2. 交给线程池处理
        //tp->Push(t);

        ThreadPool<Task>::GetInstance()->Push(t);

        std::cout << "main thread make task: " << t.GetTask() << std::endl;

        sleep(1);
    }

}